Contents | Index | < Browse | Browse >
LETTERasctimeULETTER
Creates a string consisting of date and time.
Overview
#include <time.h>
tp = asctime (t);
char *tp; // destination string address
const struct tm *t; // source tm structure
Portability
ANSI
Description
"asctime" is a cut-down version of "strftime" and converts the time from
"*t" into a string formatted like "Tue Apr 07 01:03:42 1992". This string
will be copied into an internal buffer and a pointer will be returned.
Returns
The function returns an ASCII string which will always be exactly 26 chars
long. The string will have the form:
"DDD MMM dd hh:mm:ss YYYY\n\0"
DDD is the weekday, MMM the month, dd is the current day in this month,
hh:mm:ss stands for Hours:Minutes:Seconds and YYYY is the current year.
For example:
"Wed Oct 25 12:05:43 1995\n\0"
The string buffer is shared among the "asctime" and "ctime"
functions.
See also
ctime , gmtime , localtime , strftime , time
Example
#include <stdio.h>
#include <time.h>
void main(void)
{
struct tm *tp;
time_t t;
time(&t);
tp = localtime(&t);
printf("The current time is %s\n",asctime(tp));
}